<?php

namespace app\model\zs;

use app\mytrait\ArrTrait;
use think\Model;

class ZsBusinessGrassConf extends Model
{
    use ArrTrait;

    // 设置当前模型对应的完整数据表名称
    protected $table = 'business_grass_confs';

    // 设置当前模型的数据库连接
    protected $connection = 'zs';

    // 自动写入时间的类型
    protected $autoWriteTimestamp = 'datetime';

    // 定义时间戳字段名
    protected $createTime = 'create_at';
    protected $updateTime = 'update_at';

    const STATUS_ON = 1;
    const STATUS_OFF = 2;

    const TYPE_GRASS = 1;

    public static function typeRels()
    {
        return [
            static::TYPE_GRASS => '种草奖励',
        ];
    }

    public function getCouponTidArrAttr($value)
    {
        return array_filter(json_decode($value, true) ?: []);
    }

    public function setCouponTidArrAttr($value)
    {
        $arr = $this->arrQuote($value);
        return $arr ? json_encode($arr, JSON_UNESCAPED_UNICODE) : '';
    }
}
